<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/jquery-3.3.1.js"></script>
</head>
<body>
    <div>
        <ul>
            <li><span>1</span></li>
            <li><span>2</span></li>
            <li><span>3</span></li>
        </ul>
    </div>
    <script>
        {
            let ele = $("<h1></h1>").html("我是标题");
            $("ul li:eq(1)").append(ele);
        }
        {
            $(document).on("click",function(){
                $("ul").append($("<li></li>").html("我是新加进来的li"));
            })
        }
        {
            $(document).click(function(){
                $("<li></li>").html("我也是刚加进来的li").appendTo($("ul"))
            });
        }
        {
            $(document).click(function(){
                $("<li></li>").html("到第一个后面").insertAfter($("li:contains(1)"));
            });
        }
        {
            $(document).click(function(){
                $("<li></li>").html("到第三个前面").insertBefore($("li:eq(2)"));
            });
        }
    </script>
</body>
</html>